""" 
Copyright 2009 Texas A&M University
 
Licensed under the Apache License, Version 2.0 (the "License"); you may not use 
this file except in compliance with the License. You may obtain a copy of the 
License at

http://www.apache.org/licenses/LICENSE-2.0
  
Unless required by applicable law or agreed to in writing, software distributed 
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY KIND, either express or implied. See the License for the 
specific language governing permissions and limitations under the License.
"""

import zope.interface

from Acquisition import aq_inner,aq_parent

from Products.Five.browser import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile

from plone.memoize.view import memoize, memoize_contextless

from meercat.ui.plone.interfaces import IMeercatConnectionManager



class BaseView(BrowserView):
    def __init__(self, context, request):
        super(BrowserView,self).__init__(context, request)
        self.manager = aq_inner(self.context).getMeercatManager()
    
    @memoize_contextless
    def portal_url(self):
        return aq_inner(self.context).absolute_url()
    
    @memoize
    def getSolrConnection(self):
        return self.manager.getSolrConnection()
    
    @memoize
    def getRestConnection(self):
        return self.manager.getRestConnection()
    
    def query(self,**params):
        return self.manager.query(**params)